Skip to content

feat: Complete Pi coding agent integration#233

Closed
hjanuschka wants to merge 3 commits intoentireio:mainfrom
hjanuschka:feat/pi-agent-complete
Closed

feat: Complete Pi coding agent integration#233
hjanuschka wants to merge 3 commits intoentireio:mainfrom
hjanuschka:feat/pi-agent-complete

Conversation

@hjanuschka
Copy link
Copy Markdown

@hjanuschka hjanuschka commented Feb 10, 2026

Summary

Complete implementation of Pi coding agent support for Entire CLI. This supersedes the skeleton in #232 with a fully functional implementation.

What's included

Agent Implementation (cmd/entire/cli/agent/pi/)

pi.go - Full Agent interface implementation:

  • DetectPresence() - Checks for .pi directory
  • ParseHookInput() - Parses JSON from pi extension hooks
  • ReadSession() / WriteSession() - JSONL transcript handling
  • GetSessionDir() - Returns ~/.pi/agent/sessions/<sanitized-path>/
  • extractModifiedFiles() - Parses write/edit tool calls from transcripts
  • TranscriptAnalyzer interface - Efficient position tracking
  • TranscriptChunker interface - Large transcript handling

hooks.go - HookSupport and HookHandler:

  • InstallHooks() - Adds npm:@hjanuschka/pi-entire to .pi/settings.json
  • UninstallHooks() - Removes the extension package
  • GetHookNames() - Returns session-start, session-end, stop, user-prompt-submit

types.go - Pi-specific data structures:

  • piHookInput - JSON input from extension
  • piSessionEntry - JSONL session line format
  • piMessage / piContentBlock - Message content types

Registry Updates

  • Added AgentNamePi and AgentTypePi constants

How it works

Pi uses an extension-based architecture rather than external hook scripts. The integration consists of:

  1. Entire CLI (this PR) - Provides the entire hooks pi <hook> commands
  2. @hjanuschka/pi-entire npm package - Pi extension that calls these hooks at lifecycle events

When entire enable --agent pi is run:

  1. The .pi/settings.json is updated with "packages": ["npm:@hjanuschka/pi-entire"]
  2. Pi loads the extension on startup
  3. Extension calls entire hooks pi session-start, etc. with JSON on stdin

Testing

# Enable in a repo
entire enable --agent pi

# Check status
entire status

Related

Companion package

The npm package @hjanuschka/pi-entire provides the pi extension side of this integration:
https://github.com/hjanuschka/pi-entire


Note

Medium Risk
Adds a new agent integration that reads/writes local files and parses untrusted JSONL transcripts/settings, so bugs could affect hook installation or session processing but core existing agents are largely untouched.

Overview
Adds Pi coding agent support to Entire CLI via a new pi agent implementation.

This introduces Pi-specific hook handling by installing/uninstalling the npm:@hjanuschka/pi-entire extension in .pi/settings.json, parsing hook JSON from stdin, and adding Pi session transcript support (JSONL read/write, truncation/checkpoint lookup, modified-file extraction, and transcript position/chunking helpers). The agent registry is updated to include AgentNamePi/AgentTypePi constants.

Written by Cursor Bugbot for commit b787315. This will update automatically on new commits. Configure here.

Implements full Pi coding agent support with:

- Complete Agent interface implementation
- JSONL transcript parsing matching Pi's session format
- Modified files extraction from write/edit tool calls
- TranscriptAnalyzer interface for efficient position tracking
- TranscriptChunker interface for large transcript handling
- HookSupport for extension-based hook installation
- HookHandler with session-start, session-end, stop, user-prompt-submit hooks
- Proper session directory detection (~/.pi/agent/sessions/)
- Extension package installation via .pi/settings.json

The implementation follows the same patterns as claudecode and geminicli agents,
with full support for:
- Hook input parsing from stdin JSON
- Session reading/writing with NativeData preservation
- File modification tracking from tool results
- Transcript position tracking for incremental updates

Works with the companion npm package @anthropic/pi-entire which provides
the pi extension that calls these hooks.

Closes entireio#221
@hjanuschka hjanuschka requested a review from a team as a code owner February 10, 2026 23:36
- GetLastUserPrompt() - Extract last user prompt from session
- TruncateAtUUID() - Truncate session at entry ID for rewind
- FindCheckpointUUID() - Find entry ID for tool call (checkpoint lookup)
- CalculateTokenUsage() - Basic token usage tracking

Also fix package name to @hjanuschka/pi-entire
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 6 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

Fixes all 6 issues identified in PR entireio#233 code review:

High Severity:
- Pi agent registration: Added side-effect imports to hooks_cmd.go and
  config.go to ensure Pi agent init() runs and registers with the agent
  registry. Without this, 'entire hooks pi' commands were non-functional.

- Settings round-trip preservation: Refactored InstallHooks, UninstallHooks,
  and AreHooksInstalled to use map[string]json.RawMessage pattern (matching
  Claude agent) to preserve unknown JSON fields in .pi/settings.json instead
  of unmarshaling into PiSettings struct that only has Packages/Extensions.

Medium Severity:
- Incremental file extraction: Added assistant message handling to
  ExtractModifiedFilesFromOffset to match extractModifiedFiles behavior.
  Now extracts file paths from both toolResult messages AND assistant
  messages with toolCall content blocks (write/edit).

Low Severity:
- Line counting consistency: Fixed off-by-one in GetTranscriptPosition
  to count last line even when it lacks trailing newline, matching
  ExtractModifiedFilesFromOffset behavior.

- Dead code removal: Removed unreachable .pi/settings.json check in
  DetectPresence (can't exist if .pi directory doesn't exist).

- Constant deduplication: Removed local AgentNamePi/AgentTypePi constants,
  now using agent.AgentNamePi/AgentTypePi from registry like Claude/Gemini
  agents do.

Closes cursor-bot review feedback on PR entireio#233.
@hjanuschka
Copy link
Copy Markdown
Author

ready for review!

@squishykid squishykid added enhancement New feature or request agent-support adding support for additional AI agents labels Feb 16, 2026
@squishykid
Copy link
Copy Markdown
Member

@hjanuschka we are working on an improved agent interface, once that's merged we will be able to add Pi coding!

#281

@hjanuschka
Copy link
Copy Markdown
Author

hjanuschka commented Feb 16, 2026 via email

@khaong khaong added on-hold Blocked on other work competing-pr Multiple PRs addressing the same thing — needs team decision labels Feb 17, 2026
@ManuelHettich
Copy link
Copy Markdown

Is this ready to be merged now that #281 has been finished or does it require a refactor?

@nodo
Copy link
Copy Markdown
Contributor

nodo commented Mar 30, 2026

👋 @hjanuschka thank you for your contribution! We shifted pattern and introduced pi as an external agent plugin (entireio/external-agents#6). Let us know if you have any feedback on that and more contributions are always welcome ❤️

@nodo nodo closed this Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-support adding support for additional AI agents competing-pr Multiple PRs addressing the same thing — needs team decision enhancement New feature or request on-hold Blocked on other work

Development

Successfully merging this pull request may close these issues.

Agent integration: Pi coding agent

5 participants